package com.qqs.stock.exception;


import com.qqs.stock.dto.DeductStockOrderPromise;
import com.qqs.stock.utils.DeductStockConvert;
import com.qqs.stock.vo.DeductStockOrderVo;
import lombok.Getter;

public class DeductStockException extends RuntimeException {
    @Getter
    private final DeductStockOrderVo response;

    public DeductStockException(DeductStockOrderVo response) {
        this.response = response;
    }

    public DeductStockException(String message, DeductStockOrderVo response) {
        super(message);
        this.response = response;
    }

    public DeductStockException(String message, Throwable cause, DeductStockOrderVo response) {
        super(message, cause);
        this.response = response;
    }

    public static void newThrow(DeductStockOrderPromise promise) {
        DeductStockOrderVo response = DeductStockConvert.convert(promise);
        throw new DeductStockException(response);
    }

    public static void newThrow(String message, DeductStockOrderPromise promise) {
        DeductStockOrderVo response = DeductStockConvert.convert(promise);
        throw new DeductStockException(message, response);
    }

    public static void newThrow(String message, Throwable cause, DeductStockOrderPromise promise) {
        DeductStockOrderVo response = DeductStockConvert.convert(promise);
        throw new DeductStockException(message, cause, response);
    }
}
